<!DOCTYPE html>
<html>
	{include file="head.html"}

	<body>
		<script>
			var uploader_object_id = "{$data.id}",
				uploader_tablename = "forum";
		</script>
		<div class="fullscreen">

			<div class="topfixed">
				<div class="t_left">
					<a href="/index.php?m=forum&a=my" class="goBack"><i class="back"></i></a>
				</div>
				<div class="t_main">发布帖子</div>
				<div class="t_right">
					<a href="javascript:;" class="t_right_post" id="post-submit">发送</a>
				</div>
			</div>
			<div class="paddingheight"></div>

			<div id="page">

				<div class="main-body pd-5 bg-fff">
					<form method="post" action="{$appadmin}?m=forum&a=save&ajax=1" id="upload_form" class="form-horizontal ">
						<input type="hidden" name="id" value="{$data.id}" />
						<input type="hidden" name="imgurl" id="imgurl" class="imgurl" value="{$data.imgurl}">
						<div class="input-row">

							<input type="text" name="title" class="txt" id="title" value="{$data.title}" placeholder="请输标题">

						</div>

						<div class="input-flex">
							<div class="label">分类</div>
							<select name="catid" class="select">
								<option value="0">请选择</option>
								{foreach item=c from=$cat_list}
								<option value="{$c.catid}" {if $data.catid eq $c.catid or get( 'catid') eq $c.catid} selected="selected" {/if}>{$c.cname}</option>
								{foreach item=c_2 from=$c.child}
								<option value="{$c_2.catid}" {if $data.catid eq $c_2.catid or get( 'catid') eq $c_2.catid} selected="selected" {/if} class="o_c_2">|__{$c_2.cname}</option>
								{foreach item=c_3 from=$c_2.child}
								<option value="{$c_3.catid}" {if $data.catid eq $c_3.catid or get( 'catid') eq $c_3.catid} selected="selected" {/if} class="o_c_3"> |____{$c_3.cname}</option>
								{/foreach} {/foreach} {/foreach}
							</select>

						</div>

						<div class="clearfix"></div>

						<div class="textarea-row">
							<label>内容</label>
							<textarea id="content" name="content" style="display: none;">{$data.content}</textarea>
							<div id="js-content" contenteditable="" class="sky-editor-content">
								{$data.content}
							</div>
						</div>
						{include file="inc/uploader.html"}

						<div style="clear:both;"></div>
					</form>
				</div>
				{include file="footer.html"}
			</div>
			<script src="/plugin/lrz/lrz.bundle.js"></script>
			<script src="/plugin/skyeditor/skyeditor.js"></script>
			<script>
				$(function() {
					$("#post-submit").on("click", function() {
						if($("#uploaderFiles li").length > 0) {
							$("#imgurl").val($("#uploaderFiles li").eq(0).attr("v"));
						}
						$("#content").val($("#js-content").html());
						$.post($("#upload_form").attr("action"), $("#upload_form").serialize(), function(data) {

							if(!data.error) {
								skyToast("发布成功");
								setTimeout(function() {
									goBack();
								}, 1000);
							} else {
								skyToast(data.message);
							}
						}, "json");
					});
				});
			</script>

	</body>

</html>